package com.xiaoma.tpo.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.BonusSignAchievement;
import com.xiaoma.tpo.dto.BonusBoard;

@Repository
public class BonusSignAchievementDao extends BaseDaoImpl<BonusSignAchievement>{

    @SuppressWarnings("unchecked")
    public List<BonusBoard> findUserSignAchievements(int userId) {
        String sql = "SELECT a.user_id, b.img, b.title, sum(c.bonus_point) as bonus_point FROM bonus_sign_achievement a left join bonus_sign_rule b on a.bonus_sign_rule_id = b.id left join bonus_user_sign c on a.user_id = c.user_id where a.user_id = ? group by null limit 1";
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(BonusBoard.class, getNameHandler()), userId);
        return (List<BonusBoard>)result;
    }
}
